#!/bin/bash
IP=`ip a|grep inet|grep -v 127.0.0.1|grep -v inet6|grep -v 192.168.122.1|awk {'print $2'}|awk -F/ {'print $1'}`
cat > /home/taiga/taiga-back/settings/local.py <<EOF
from .development import *  
from .common import *  
DATABASES = {  
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'taiga',
        'USER': 'taiga',
        'PASSWORD': 'J5brHrAXFLQSif0K',
        'HOST': '',
        'PORT': '',
    }
}
MEDIA_URL = "http://$IP/media/"  
STATIC_URL = "http://$IP/static/"  
ADMIN_MEDIA_PREFIX = "http://$IP/static/admin/"  
SITES["front"]["scheme"] = "http"  
SITES["front"]["domain"] = "$IP"  
SECRET_KEY = "2k_DRTqCjy$&-Rul^C23Brf=DY80DLZCl7VF*xU$*ert7-6VccT"
EOF
chown taiga.taiga /home/taiga/taiga-back/settings/local.py
echo "RUN"
echo "python3.5 manage.py runserver 0.0.0.0:8000 --insecure"
echo
echo "visit"
echo "http://$IP:8000/api/v1"  

